<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<title>用户登录</title>
<style type="text/css">
#body {
	 margin-top: 350px;
	margin-left: 500px; 
}
#body1{
background-size:100% 90%; 
}
</style>
<!-- Bootstrap -->
<link href="/sc/css/bootstrap.min.css" rel="stylesheet">
<script src="/sc/js/jquery-3.1.1.min.js"></script>
<script src="/sc/js/bootstrap.min.js"></script>
<script type="text/javascript">
  
	$(function() {
		 var count=0;
		$("#name").blur(function() {
			var name = $("#name").val();
			if(name==""){
				count++;
				$("#checkName").html("<font color='red' size='3'>用户名不能为空</font>");
			}else{
			$.post("${ctxPath}/user/checkName", {
				"name" : name
			}, function(data) {
				$("#checkName").html("<font color='red' size='3'>"+data+"</font>");
			});
			}
		});
		
		$("#pwd").blur(function(){
			if(count!=0){
				count--;
			}
			var pwd=$("#pwd").val();
			if(pwd==""){
				count++;
				$("#checkPwd").html("<font color='red' size='3'>密码不能为空</font>");
			}else {
				$("#checkPwd").hide();
			}
		});
		
		
		
		 $("form").submit(function(){
			if(count>0){
			return false;
			}else if(count==0){
				return true;
			}
		}); 
	});
</script>

</head>
<body background="/sc/img/bg1.jpg" id="body1">
	<div id="body">
		<form class="form-horizontal" method="post" action="${ctxPath}/user/userLogin">
			<div class="form-group">
				<label  class="col-sm-2 control-label">用户</label>
				<div class="col-xs-3">
					<input type="text" class="form-control" name="username" id="name"
						placeholder="请输入用户名">
				</div><span id="checkName"></span>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">密码</label>
				<div class="col-xs-3">
					<input type="password" class="form-control" name="password" id="pwd"
						placeholder="请输入密码">
				</div><span id="checkPwd"><font color="red" size='3'>${mes!}</font></span>
			</div>

			<div class="form-group" id="fg1">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-default" id="sub">登录</button>
					<a href="${ctxPath}/user/registerIn.html"><button type="button" class="btn btn-default">免费注册</button></a>
				</div>
			</div>
		</form>
	</div>
</body>
</html>